clear all
set more off
cap log close

********************************************************************************
***** Project: The Short and Long Term Effects of In-Person Performance Feedback
********************************************************************************
***** A. R. Soetevent & G. J. Romensen
********************************************************************************
***** Collecting driver information
********************************************************************************
***** Latest update: 18-01-2020
********************************************************************************
*global filepath "C:\JPEMicReplication"
log using "$filepath/Logs/04Driverinformation.log", replace

*** 1. Retrieve driver ids.

import delimited "$filepath\Data\Randomisatie\RandomisatieFinal.csv"

rename rugnr chauf_nr_rug

sort chauf_nr_rug

levelsof chauf_nr_rug, local(levels_rugnr)
global levels_rugnr `levels_rugnr'

clear

*** 2. Drop drivers that are not part of the study. 

import excel "$filepath\Data\Using databases\Medewerkers.xlsx", firstrow

foreach var of varlist _all {
rename `var' `=lower("`var'")'
}

rename rugnr chauf_nr_rug

gen rugcheck=.
foreach x of global levels_rugnr {
replace rugcheck=1 if chauf_nr_rug=="`x'"
}

drop if rugcheck!=1
drop rugcheck

*** 3. Prepare driver-specific information. 

replace geslacht="0" if geslacht=="M"
replace geslacht="1" if geslacht=="V"
destring geslacht, replace
label variable geslacht "V=1, M=0"

gen verjaardag=date(string(geboren, "%td"), "DMY")
format verjaardag %td

gen jaarindienst=date(string(indienstdienstjrjubileumte, "%td"), "DMY")
format jaarindienst %td

destring chauf_nr_rug, replace
order chauf_nr_rug 

gen fulltimer=cond(fte>=0.9,1,0)

drop geboren dienstbetrekking functie eindecontract indienstdienstjrjubileumte

sort chauf_nr_rug standplaats

save "$filepath\Data\Using databases\Medewerkers.dta", replace
